import { Loading } from "element-ui";
import Vue from "vue";

let loadingInstance = null;
export const viewLoading = (flag = true) => {
  Vue.nextTick(() => {
    let target = document.querySelector(".avue-view-main");
    try {
      if (flag && loadingInstance == null) {
        loadingInstance = Loading.service({
          target,
          fullscreen: false,
        });
      } else if (!flag && loadingInstance) {
        loadingInstance.close();
      }
      return loadingInstance;
    } catch (err) {
      console.log("catch error----> ", err);
    }
  });
};
